<?php
class Dialogs extends CActiveRecord {
    
    public $dialogId;
    public $lastMessId;
    public $user1Id;
    public $user2Id;
    public $user1Del;
    public $user2Del;
    public $user1New;
    public $user2New;
    
    public static function model($className = __CLASS__) {
        return parent::model($className);
    }

    public function tableName() {
        return 'messages_dialogs';
    }
    
    public function relations() {
        return array(
            'lastMessage'=>array(self::HAS_ONE, 'Messages', array('id'=>'lastMessId')),
        );
    }
    
    public function pagination($limit, $offset) {
        $this->getDbCriteria()->mergeWith(array(
            'offset' => $offset,
            'limit' => $limit,
        ));
        return $this;
    }
}
